package midoo.server.core;

import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelOption;
import io.netty.channel.MessageSizeEstimator;
import io.netty.channel.RecvByteBufAllocator;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by ajianzheng on 2015/4/11.
 */
public class MServerBootstrapOption {
    private Map<ChannelOption, Object> options = new HashMap<ChannelOption, Object>();

    private ByteBufAllocator ALLOCATOR;
    private RecvByteBufAllocator RCVBUF_ALLOCATOR;
    private MessageSizeEstimator MESSAGE_SIZE_ESTIMATOR;
    private Integer CONNECT_TIMEOUT_MILLIS;
    private Integer MAX_MESSAGES_PER_READ;
    private Integer WRITE_SPIN_COUNT;
    private Integer WRITE_BUFFER_HIGH_WATER_MARK;
    private Integer WRITE_BUFFER_LOW_WATER_MARK;
    private Boolean ALLOW_HALF_CLOSURE;
    private Boolean AUTO_READ;
    private Boolean SO_BROADCAST;
    private Boolean SO_KEEPALIVE;
    private Integer SO_SNDBUF;
    private Integer SO_RCVBUF;
    private Boolean SO_REUSEADDR;
    private Integer SO_LINGER;
    private int SO_BACKLOG;
    private Integer SO_TIMEOUT;
    private Integer IP_TOS;
    private InetAddress IP_MULTICAST_ADDR;
    private NetworkInterface IP_MULTICAST_IF;
    private Integer IP_MULTICAST_TTL;
    private Boolean IP_MULTICAST_LOOP_DISABLED;
    private Boolean TCP_NODELAY;

    public Map<ChannelOption, Object> getOptions() {
        return options;
    }

    public void setOptions(Map<ChannelOption, Object> options) {
        this.options = options;
    }

    /**
     * 以下为options参数
     * 以下为options参数
     * 以下为options参数
     * @return
     */
    public ByteBufAllocator getALLOCATOR() {
        return ALLOCATOR;
    }

    public void setALLOCATOR(ByteBufAllocator ALLOCATOR) {
        this.ALLOCATOR = ALLOCATOR;
        options.put(ChannelOption.ALLOCATOR, ALLOCATOR);
    }

    public RecvByteBufAllocator getRCVBUF_ALLOCATOR() {
        return RCVBUF_ALLOCATOR;
    }

    public void setRCVBUF_ALLOCATOR(RecvByteBufAllocator RCVBUF_ALLOCATOR) {
        this.RCVBUF_ALLOCATOR = RCVBUF_ALLOCATOR;
        options.put(ChannelOption.RCVBUF_ALLOCATOR, RCVBUF_ALLOCATOR);
    }

    public MessageSizeEstimator getMESSAGE_SIZE_ESTIMATOR() {
        return MESSAGE_SIZE_ESTIMATOR;
    }

    public void setMESSAGE_SIZE_ESTIMATOR(MessageSizeEstimator MESSAGE_SIZE_ESTIMATOR) {
        this.MESSAGE_SIZE_ESTIMATOR = MESSAGE_SIZE_ESTIMATOR;
        options.put(ChannelOption.MESSAGE_SIZE_ESTIMATOR, MESSAGE_SIZE_ESTIMATOR);
    }

    public Integer getCONNECT_TIMEOUT_MILLIS() {
        return CONNECT_TIMEOUT_MILLIS;
    }

    public void setCONNECT_TIMEOUT_MILLIS(Integer CONNECT_TIMEOUT_MILLIS) {
        this.CONNECT_TIMEOUT_MILLIS = CONNECT_TIMEOUT_MILLIS;
        options.put(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT_MILLIS);
    }

    public Integer getMAX_MESSAGES_PER_READ() {
        return MAX_MESSAGES_PER_READ;
    }

    public void setMAX_MESSAGES_PER_READ(Integer MAX_MESSAGES_PER_READ) {
        this.MAX_MESSAGES_PER_READ = MAX_MESSAGES_PER_READ;
        options.put(ChannelOption.MAX_MESSAGES_PER_READ, MAX_MESSAGES_PER_READ);
    }

    public Integer getWRITE_SPIN_COUNT() {
        return WRITE_SPIN_COUNT;
    }

    public void setWRITE_SPIN_COUNT(Integer WRITE_SPIN_COUNT) {
        this.WRITE_SPIN_COUNT = WRITE_SPIN_COUNT;
        options.put(ChannelOption.WRITE_SPIN_COUNT, WRITE_SPIN_COUNT);
    }

    public Integer getWRITE_BUFFER_HIGH_WATER_MARK() {
        return WRITE_BUFFER_HIGH_WATER_MARK;
    }

    public void setWRITE_BUFFER_HIGH_WATER_MARK(Integer WRITE_BUFFER_HIGH_WATER_MARK) {
        this.WRITE_BUFFER_HIGH_WATER_MARK = WRITE_BUFFER_HIGH_WATER_MARK;
        options.put(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, WRITE_BUFFER_HIGH_WATER_MARK);
    }

    public Integer getWRITE_BUFFER_LOW_WATER_MARK() {
        return WRITE_BUFFER_LOW_WATER_MARK;
    }

    public void setWRITE_BUFFER_LOW_WATER_MARK(Integer WRITE_BUFFER_LOW_WATER_MARK) {
        this.WRITE_BUFFER_LOW_WATER_MARK = WRITE_BUFFER_LOW_WATER_MARK;
        options.put(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, WRITE_BUFFER_LOW_WATER_MARK);
    }

    public Boolean getALLOW_HALF_CLOSURE() {
        return ALLOW_HALF_CLOSURE;
    }

    public void setALLOW_HALF_CLOSURE(Boolean ALLOW_HALF_CLOSURE) {
        this.ALLOW_HALF_CLOSURE = ALLOW_HALF_CLOSURE;
        options.put(ChannelOption.ALLOW_HALF_CLOSURE, ALLOW_HALF_CLOSURE);
    }

    public Boolean getAUTO_READ() {
        return AUTO_READ;
    }

    public void setAUTO_READ(Boolean AUTO_READ) {
        this.AUTO_READ = AUTO_READ;
        options.put(ChannelOption.AUTO_READ, AUTO_READ);
    }

    public Boolean getSO_BROADCAST() {
        return SO_BROADCAST;
    }

    public void setSO_BROADCAST(Boolean SO_BROADCAST) {
        this.SO_BROADCAST = SO_BROADCAST;
        options.put(ChannelOption.SO_BROADCAST, SO_BROADCAST);
    }

    public Boolean getSO_KEEPALIVE() {
        return SO_KEEPALIVE;
    }

    public void setSO_KEEPALIVE(Boolean SO_KEEPALIVE) {
        this.SO_KEEPALIVE = SO_KEEPALIVE;
        options.put(ChannelOption.SO_KEEPALIVE, SO_KEEPALIVE);
    }

    public Integer getSO_SNDBUF() {
        return SO_SNDBUF;
    }

    public void setSO_SNDBUF(Integer SO_SNDBUF) {
        this.SO_SNDBUF = SO_SNDBUF;
        options.put(ChannelOption.SO_SNDBUF, SO_SNDBUF);
    }

    public Integer getSO_RCVBUF() {
        return SO_RCVBUF;
    }

    public void setSO_RCVBUF(Integer SO_RCVBUF) {
        this.SO_RCVBUF = SO_RCVBUF;
        options.put(ChannelOption.SO_RCVBUF, SO_RCVBUF);
    }

    public Boolean getSO_REUSEADDR() {
        return SO_REUSEADDR;
    }

    public void setSO_REUSEADDR(Boolean SO_REUSEADDR) {
        this.SO_REUSEADDR = SO_REUSEADDR;
        options.put(ChannelOption.SO_REUSEADDR, SO_REUSEADDR);
    }

    public Integer getSO_LINGER() {
        return SO_LINGER;
    }

    public void setSO_LINGER(Integer SO_LINGER) {
        this.SO_LINGER = SO_LINGER;
        options.put(ChannelOption.SO_LINGER, SO_LINGER);
    }

    public Integer getSO_BACKLOG() {
        return SO_BACKLOG;
    }

    public void setSO_BACKLOG(Integer SO_BACKLOG) {
        this.SO_BACKLOG = SO_BACKLOG;
        options.put(ChannelOption.SO_BACKLOG, SO_BACKLOG);
    }

    public Integer getSO_TIMEOUT() {
        return SO_TIMEOUT;
    }

    public void setSO_TIMEOUT(Integer SO_TIMEOUT) {
        this.SO_TIMEOUT = SO_TIMEOUT;
        options.put(ChannelOption.SO_TIMEOUT, SO_TIMEOUT);
    }

    public Integer getIP_TOS() {
        return IP_TOS;
    }

    public void setIP_TOS(Integer IP_TOS) {
        this.IP_TOS = IP_TOS;
        options.put(ChannelOption.IP_TOS, IP_TOS);
    }

    public InetAddress getIP_MULTICAST_ADDR() {
        return IP_MULTICAST_ADDR;
    }

    public void setIP_MULTICAST_ADDR(InetAddress IP_MULTICAST_ADDR) {
        this.IP_MULTICAST_ADDR = IP_MULTICAST_ADDR;
        options.put(ChannelOption.IP_MULTICAST_ADDR, IP_MULTICAST_ADDR);
    }

    public NetworkInterface getIP_MULTICAST_IF() {
        return IP_MULTICAST_IF;
    }

    public void setIP_MULTICAST_IF(NetworkInterface IP_MULTICAST_IF) {
        this.IP_MULTICAST_IF = IP_MULTICAST_IF;
        options.put(ChannelOption.IP_MULTICAST_IF, IP_MULTICAST_IF);
    }

    public Integer getIP_MULTICAST_TTL() {
        return IP_MULTICAST_TTL;
    }

    public void setIP_MULTICAST_TTL(Integer IP_MULTICAST_TTL) {
        this.IP_MULTICAST_TTL = IP_MULTICAST_TTL;
        options.put(ChannelOption.IP_MULTICAST_TTL, IP_MULTICAST_TTL);
    }

    public Boolean getIP_MULTICAST_LOOP_DISABLED() {
        return IP_MULTICAST_LOOP_DISABLED;
    }

    public void setIP_MULTICAST_LOOP_DISABLED(Boolean IP_MULTICAST_LOOP_DISABLED) {
        this.IP_MULTICAST_LOOP_DISABLED = IP_MULTICAST_LOOP_DISABLED;
        options.put(ChannelOption.IP_MULTICAST_LOOP_DISABLED, IP_MULTICAST_LOOP_DISABLED);
    }

    public Boolean getTCP_NODELAY() {
        return TCP_NODELAY;
    }

    public void setTCP_NODELAY(Boolean TCP_NODELAY) {
        this.TCP_NODELAY = TCP_NODELAY;
        options.put(ChannelOption.TCP_NODELAY, TCP_NODELAY);
    }
}
